package com.easygem.front.service.imp;

import com.easygem.common.model.system.User;
import com.easygem.common.vo.system.PageVO;
import com.easygem.front.mapper.OutUserMapper;
import com.easygem.front.service.OutUserService;
import com.easygem.front.service.base.AbstractServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 肖智
 * @version 1.0
 * @Description TODO
 * @date 2025/3/4
 */
@Service
public class OutUserServiceImpl extends AbstractServiceImpl<OutUserMapper, User, Integer> implements OutUserService {
    @Autowired
    private OutUserMapper outUserMapper;

    //加载离职员工
    @Override
    public PageVO<User> selectOutUserList(Integer pageNum, Integer pageSize,String accountName) {
        PageHelper.startPage(pageNum, pageSize);
        try {
            List<User> userList = outUserMapper.selectOutUserList(accountName);
            PageInfo<User> info = new PageInfo<>(userList);
            return new PageVO<>(info.getTotal(), userList);
        } finally {
            PageHelper.clearPage(); // 清理分页参数
        }
    }

    //根据用户id获取资源id
    @Override
    public Long[] getResourceIdByUserId(Long userId) {
        return outUserMapper.getResourceIdByUserId(userId);
    }

    //根据用户id获取客户id
    @Override
    public Long[] getClientIdByUserId(Long userId) {
        return outUserMapper.getClientIdByUserId(userId);
    }

    @Override
    public Integer deleteResource(Long[] resourceIds) {
        return outUserMapper.deleteResource(resourceIds);
    }
}
